<h1>Servicos</h1>

<% if @servicos.empty? %>
  Nenhum servico cadastrado!
<% else %>
  <table border='1'>
    <tr>
      <th>Descricao curta</th>
      <th>Preco</th>
      <th></th>
      <th></th>
    </tr>

    <% @servicos.each do |servico| %>
      <tr>
        <td><%= servico.desc_curta %></td>
        <td><%= servico.preco %></td>
        <td><%= link_to 'Detalhes', servico %></td>
        <% if current_user.type != 'Hospede' %>
          <td><%= link_to 'Editar', edit_servico_path(servico) %></td>
          <td><%= link_to 'Remover', servico, confirm: 'Tem certeza?', method: :delete %></td>
        <% else %>
          <td><%= link_to 'Adquirir', new_requisicao_path(:servico_id => servico.id, :estornado => 0) %> </td>
        <% end %>
      </tr>
    <% end %>
  </table>
<% end %>
<br />

<% if current_user.type != "Hospede" %>
  <%= link_to 'Novo servico', new_servico_path %>
<% end %>
